package com.ygs.secs.controller;

import com.alibaba.fastjson.JSON;
import com.ygs.secs.model.AuthInfomation;
import com.ygs.secs.service.AuthInfomationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@RequestMapping("/ygssecs")
@Controller
public class AuthInfomationController {
    @Autowired
    AuthInfomationService authInfomationService;
    PlatformTransactionManager transactionManager;

    /**
     * 添加认证信息
     *
     * @param jsonauthinfo
     * @return
     */
    @ResponseBody
    @RequestMapping("/addAuthinfo")
    public Map<String, Object> addAuthinfo(String jsonauthinfo) {
        Map<String, Object> map = new HashMap<>();
        AuthInfomation authInfomation = null;
        try {
            authInfomation = JSON.parseObject(jsonauthinfo, AuthInfomation.class);
            int i = authInfomationService.insertSelective(authInfomation);
            if (i > 0) {
                map.put("code", 200);
                map.put("msg", "认证信息添加成功");
            } else {
                map.put("code", 500);
                map.put("msg", "认证信息添加失败");
            }
        } catch (Exception e) {
            map.put("code", 500);
            map.put("msg", "认证信息添加失败");
        }
        return map;
    }
}
